package gof_003_行为型_Behavioral.gof_005_责任链_ChainOfResponsibility.gof_001_Normal;

import java.util.Scanner;
import java.util.concurrent.TimeUnit;

public class Main {
    public static void main(String[] args) {
        double num = getDays();


        System.out.println("向组长请假...");
        sleep(1);
        System.out.println("组长同意!");
        if (num <= 1) {
            return;
        }


        System.out.println("向经理请假...");
        sleep(1);
        System.out.println("经理同意!!");
        if (num <= 5) {
            return;
        }


        System.out.println("向老板请假...");
        sleep(1);
        if (num <= 7) {
            System.out.println("老板同意!!!");
            return;
        } else {
            System.out.println("拒绝!");
        }
    }

    /**
     * 从控制台输入请假的天数
     * @return
     */
    private static double getDays() {
        System.out.println("请输入请假天数:");
        Scanner scanner = new Scanner(System.in);
        double v = scanner.nextDouble();
        return v;
    }

    /**
     * 模拟睡眠
     *
     * @param seconds
     */
    private static void sleep(int seconds) {
        try {
            TimeUnit.SECONDS.sleep(seconds);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}